package com.john.seckill.controller;

import com.john.seckill.service.IUserService;
import com.john.seckill.vo.LoginVo;
import com.john.seckill.vo.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @Classname LoginController
 * @Description TODO
 * @Date 2021/5/19 14:30
 * @Created by john
 */
@Controller
@RequestMapping("/register")
@Slf4j
public class RegisterController {
    @Autowired
    private IUserService userService;

    @RequestMapping("/toRegister")
    public String toLogin(){
        return "register";
    }

    @RequestMapping("/doRegister")
    @ResponseBody
    public ResultBean doLogin(@Valid LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){
        log.info(String.valueOf(loginVo));
        return userService.doLogin(loginVo,request,response);
    }
}
